package com.lzk.jetpacktest.service

import android.app.Service
import android.content.Intent
import android.os.Binder
import android.os.IBinder
import android.util.Log

/**
 * Author: LiaoZhongKai.
 * Date: 2021/10/30
 * Function:
 */
class MyService : Service() {

    private val TAG = "MyService"

    override fun onCreate() {
        Log.d(TAG,"onCreate()")
        super.onCreate()
    }

    override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
        Log.d(TAG,"onStartCommand()")
        Log.d(TAG,"onStartCommand() Intent参数:${intent?.getStringExtra("args")}")
        return super.onStartCommand(intent, flags, startId)
    }

    override fun onBind(intent: Intent?): IBinder? {
        Log.d(TAG,"onBind()")
        return MyBinder()
    }

    override fun onDestroy() {
        Log.d(TAG,"onDestroy()")
        super.onDestroy()
    }
}

class MyBinder : Binder(){

    fun getInfo(): String{
        return "调用了Binder中的方法"
    }
}
